import request from '@/plugin/axios'
import util from '@/libs/util.js'

export default {

	list (data) {
		return request({
			url: 'rateBoc/list',
			headers: {},
			method: 'post',
			data,
		});
	},
	getOptions(data) {
		return request({
			url: 'currencyCode/list',
			headers: {},
			method: 'post',
			data,
		});
	},
	getrateBocOptions (data = {}) {

		return new Promise ((resolve, reject) => {
			request({
				url: 'currencyCode/list',
				headers: {},
				method: 'post',
				data,
			})
			.then(re => {

				var list = re.list;
				var options = [];

				list.forEach(item => options.push({value: item.code, label: `${item.code}-${item.name}`}));

				resolve(options);
			})
			.catch(err => {
				reject(err);
			});
		});
	},

	getRate (data) {
		return request({
			url: 'rateBoc/getrate',
			headers: {},
			method: 'post',
			data,
		});
	},

	getHistoryList (data) {
		return request({
			url: 'rateBoc/loglist',
			headers: {},
			method: 'post',
			data,
		});
	},

};